package com.net.xpay.common.manager.impl.stat;

import com.google.common.base.Preconditions;
import com.net.xpay.common.manager.stat.CompanyBillDailyStatManager;
import com.net.common.annotation.ReadTransactional;
import com.net.common.dao.BasicMapper;
import com.net.common.dao.Page;
import com.net.common.manager.AbstractManager;
import com.net.xpay.common.dao.stat.CompanyBillDailyStatMapper;
import com.net.xpay.common.domain.stat.CompanyBillDailyStat;
import com.net.xpay.common.model.search.CompanyBillDailyStatSearchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@ReadTransactional
public class CompanyBillDailyStatManagerImpl extends AbstractManager<CompanyBillDailyStat> implements CompanyBillDailyStatManager {

    @Autowired
    private CompanyBillDailyStatMapper mapper;


    @Override
    protected BasicMapper<Long, CompanyBillDailyStat> getMapper() {
        return mapper;
    }

    @Override
    public List<CompanyBillDailyStat> search(CompanyBillDailyStatSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        Page page = new Page(searchModel);
        page.addOrder("day", "desc");
        return nonEmptyList(mapper.search(searchModel, page));
    }

    @Override
    public long searchCount(CompanyBillDailyStatSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        return mapper.searchCount(searchModel);
    }

    @Override
    public List<CompanyBillDailyStat> list(CompanyBillDailyStatSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        return nonEmptyList(mapper.list(searchModel));
    }

    @Override
    public CompanyBillDailyStat sumCompanyBillDailyStat(CompanyBillDailyStatSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        return mapper.sumCompanyBillDailyStat(searchModel);
    }
}
